Welcome to 4.3.8++, fondly referred to over the years (or at least since just after class on Monday) as the Java Jargon Jamboree. Here all will be revealed, and no secrets will be witheld. The context of every single word you can find in any Java program (anywhere!) will be described by one of the following terms. (Though there a few operators we have yet to look at.)
Note that through the "read" stage of learning any language, you have to know the common terms, i.e. jargon, used within that programming language community, and for Java, these are them.
At this point, a lot of what is below may be still a bit cloudy to you, but a lot you've seen and heard enough that you should be able to fit it into the grand perspective.
Example.
So as it turns out, the first half dozen or so of our 10-Step Java Caluculator program have an example of every single one of the terms above. First, here's the code, and then below a diagram. See how much you can match to the terms above on your own.
The color code for above is, generally:
green - generally data, i.e. a focus on stuff
brown - generally methods, i.e. a focus on doing stuff
red - object oriented, i.e. a focus on user made & Java classes & "OOP" programming
Try the same with any Java code. Recall the great repository of different Java (and other programming) algorithms, at RosettaCode.org.
Give this one, from there, a go. (It is an important algorithm we'll look at later on.)
1 public class BinarySearchIterative {
2 public static int binarySearch(int[] nums, int check) {
3 int hi = nums.length - 1;
4 int lo = 0;
5 while (hi >= lo) {
6 int guess = (lo + hi) /2
7 if (nums[guess] > check) {
8 hi = guess - 1;
9 } else if (nums[guess] < check) {
10 lo = guess + 1;
11 } else {
12 return guess;
13 }
14 }
15 return -1;
16 }
17
18 public static void main(String[] args) {
19 int[] haystack = {1, 5, 6, 7, 8, 11};
20 int needle = 5;
21 int index = binarySearch(haystack, needle);
22 if (index == -1) {
23 System.out.println(needle + " is not in the array");
24 } else {
25 System.out.println(needle + " is at index " + index);
26 }
27 }
28}
From the Merriam-Webster Dictionary:
(Entry 1 of 2)
noun
(Entry 1 of 2)